cmake_minimum_required(VERSION 3.10)

project(zjh)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -o2 -Wall")

include_directories(.)

set(LIB_SRC
    socket.cpp
    socketmanager.cpp
    utils/encodetool.cpp
    utils/fileutil.cpp
    buffer.cpp
    proto/test.pb.cc
    proto/message.pb.cc
    handler/accounthandler.cpp
    handler/chathandler.cpp
    handler/fighthandler.cpp
    handler/matchhandler.cpp
    netmsgcenter.cpp
    db/dbmanager.cpp
    db/mysqlres.cpp
    db/mydb.cpp
    db/redis.cpp
    log.cpp
    config.cpp
    game/player.cpp
    game/matchroom.cpp
    game/card.cpp
    )

set(LIBS
    mysqlclient
    protobuf
    yaml-cpp
    hiredis
    )

add_library(lvqiang ${LIB_SRC})

add_executable(server server.cpp)

add_executable(proto_test test/test_proto.cpp)
add_executable(mysql_test test/test_mysql.cpp)
add_executable(log_test test/test_log.cpp)
add_executable(config_test test/test_config.cpp)
add_executable(redis_test test/test_redis.cpp)

target_link_libraries(lvqiang ${LIBS} rt)

target_link_libraries(server lvqiang)
target_link_libraries(proto_test lvqiang)
target_link_libraries(mysql_test lvqiang)
target_link_libraries(log_test lvqiang)
target_link_libraries(config_test lvqiang)
target_link_libraries(redis_test lvqiang)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)